{include file="public:header"}
<!--添加栏目-->
	<form id="info_form" action="{:url('addDo')}" method="post">
		<div class="pad_lr_10">
			<div class="col_tab">
				<ul class="J_tabs tab_but cu_li">
					<li class="current">添加菜单</li>
				</ul>
				<div class="J_panes">
					<div class="content_list pad_10">
						<table width="100%" class="table_form">
							<tr>
								<th width="120">上级菜单 :</th>
								<td>
									<select class="J_cate_select mr10" data-pid="0" data-uri="{:url('ajaxGetchilds')}" data-selected="{$spid}"></select>
									<input type="hidden" name="pid" id="J_cate_id" />
									<span>默认为一级菜单</span>
								</td>
							</tr>
							<tr>
								<th>菜单事件 :</th>
								<td>
									<select name="type" id="type" onchange="hideUrl(this);">
										{volist name="typeArr" id="vo"}
										<option value="{$key}">{$vo}</option>
										{/volist}
									</select>
									<span>含有子菜单的一级菜单 可选择无</span>
								</td>
							</tr>
							<tr>
								<th>菜单名称 :</th>
								<td>
									<input type="text" name="name" id="name" placeholder="一级最多4个字符 二级最多7个字符" class="input-text" size="30">
									（可创建最多 3 个一级菜单，每个一级菜单下可创建最多 5 个二级菜单）
								</td>
							</tr>
							<tr id="tr_url" style="display:none;">
								<th>链接地址 :</th>
								<td>
									<input type="text" name="url" id="url" class="input-text" size="30"><span>以'http://'开头，例：http://fangcms.com</span>
								</td>
							</tr>
							<tr>
								<th>菜单别名 :</th>
								<td>
									<input type="text" name="alias" id="alias" class="input-text" size="20"><span>事件类型为推送事件或拍照发图时请设置菜单别名</span>
								</td>
							</tr>

						</table>
					</div>
				</div>
				<div class="mt10">
					<input value="提交" id="dosubmit" name="" class="btn btn_submit" style="margin:0 10px 0 100px;" type="submit">
					<input type="button" class="btn" value="返回" onclick="location.href='{:url("index")}'">
				</div>
			</div>
		</div>
	</form>
{include file="public:footer"}
<script>
$(function(){
	$.formValidator.initConfig({formid:"info_form",autotip:true});
	$("#name").formValidator({onshow:'请填写名称',onfocus:'请填写名称'}).inputValidator({min:1,onerror:'请填写名称'});
	$("#alias").formValidator({onshow:'请填写菜单别名',onfocus:'请填写菜单别名',empty:true,onempty:''}).regexValidator({regexp:'username',datatype:'enum',onerror:'别名只能为数字、字母、或下划线组成'});
	$('.J_cate_select').cate_select({level:1});
	$('#info_form').ajaxForm({success:complate,dataType:'json'});
	function complate(result){
		if(result.status == 1){
			$.yingloujie.tip({content:result.msg, icon:'success'});
			document.getElementById('info_form').reset();
			setTimeout(function(){window.location.reload()},3000);
		} else {
			$.yingloujie.tip({content:result.msg, icon:'error'});
		}
	}
	

});
	function hideUrl(o){
		if(o.value == 'view'){
			$("#tr_url").show();
		}else{
			$("#tr_url").hide();
		}
	}
</script>
